/*
 * PKL 51 GUNUNG KIDUL
 * Subseksie DATA ENTRY + CAPI
 */
package pkl51.controller;

import java.util.logging.Level;
import java.util.logging.Logger;
import pkl51.error.EntityException;
import pkl51.model.Blok6CModel;
import pkl51.view.kuesioner.PanelBlok6C;

/**
 *
 * @author Herlambang Permadi
 */
public class Blok6CController {

    private Blok6CModel model;

    public void setModel(Blok6CModel model) {
        this.model = model;
    }

    public void insertBlok6C(PanelBlok6C panelblok6c) throws EntityException{
        String B6CR1 = panelblok6c.getTxtB6CR1().getText();
        String B6CR2 = panelblok6c.getTxtB6CR2().getText();
        String B6CR3 = panelblok6c.getTxtB6CR3().getText();
        String B6CR4 = panelblok6c.getTxtB6CR4().getText();
        String B6CR5 = panelblok6c.getTxtB6CR5().getText();
        String B6CR6 = panelblok6c.getTxtB6CR6().getText();
        String B6CR7 = panelblok6c.getTxtB6CR7().getText();
        String B6CR8 = panelblok6c.getTxtB6CR8().getText();
        String B6CR9 = panelblok6c.getTxtB6CR9().getText();
        String B6CR10 = panelblok6c.getTxtB6CR10().getText();
        String B6CR11 = panelblok6c.getTxtB6CR11().getText();
        String B6CR12 = panelblok6c.getTxtB6CR12().getText();
        String B6CR13 = panelblok6c.getTxtB6CR13().getText();
        String B6CR14 = panelblok6c.getTxtB6CR14().getText();
        String B6CR15 = panelblok6c.getTxtB6CR15().getText();
        String B6CR16 = panelblok6c.getTxtB6CR16().getText();
        String B6CR17 = panelblok6c.getTxtB6CR17().getText();
        String B6CR18 = panelblok6c.getTxtB6CR18().getText();
        //String txtSebutkanB6CR17 = panelblok6c.getTxtSebutkanB6CR17().getText();

        model.setForDB(B6CR1, B6CR2, B6CR3, B6CR4, B6CR5, B6CR6, B6CR7, B6CR8, B6CR9, B6CR10, B6CR11, B6CR12, B6CR13, B6CR14, B6CR15, B6CR16, B6CR17, B6CR18);
        try {
            model.insertBlok6c();
        } catch (EntityException ex) {

            Logger.getLogger(Blok6CController.class.getName()).log(Level.SEVERE, null, ex);
            throw new EntityException("Gagal insert Blok 6C");
        }
    }

    public void updateBlok6C(PanelBlok6C panelblok6c) throws EntityException{
        String B6CR1 = panelblok6c.getTxtB6CR1().getText();
        String B6CR2 = panelblok6c.getTxtB6CR2().getText();
        String B6CR3 = panelblok6c.getTxtB6CR3().getText();
        String B6CR4 = panelblok6c.getTxtB6CR4().getText();
        String B6CR5 = panelblok6c.getTxtB6CR5().getText();
        String B6CR6 = panelblok6c.getTxtB6CR6().getText();
        String B6CR7 = panelblok6c.getTxtB6CR7().getText();
        String B6CR8 = panelblok6c.getTxtB6CR8().getText();
        String B6CR9 = panelblok6c.getTxtB6CR9().getText();
        String B6CR10 = panelblok6c.getTxtB6CR10().getText();
        String B6CR11 = panelblok6c.getTxtB6CR11().getText();
        String B6CR12 = panelblok6c.getTxtB6CR12().getText();
        String B6CR13 = panelblok6c.getTxtB6CR13().getText();
        String B6CR14 = panelblok6c.getTxtB6CR14().getText();
        String B6CR15 = panelblok6c.getTxtB6CR15().getText();
        String B6CR16 = panelblok6c.getTxtB6CR16().getText();
        String B6CR17 = panelblok6c.getTxtB6CR17().getText();
        String B6CR18 = panelblok6c.getTxtB6CR18().getText();
        //String txtSebutkanB6CR17 = panelblok6c.getTxtSebutkanB6CR17().getText();
        model.setForDB(B6CR1, B6CR2, B6CR3, B6CR4, B6CR5, B6CR6, B6CR7, B6CR8, B6CR9, B6CR10, B6CR11, B6CR12, B6CR13, B6CR14, B6CR15, B6CR16, B6CR17, B6CR18);
        try {
            model.updateBlok6c();
        } catch (EntityException ex) {

            Logger.getLogger(Blok6CController.class.getName()).log(Level.SEVERE, null, ex);
            throw new EntityException("Gagal update Blok 6C");
        }
    }

    public void getBlok6CyNKS(PanelBlok6C panelblok6c) throws EntityException{
        try {
            model.getBlok6cByNKS();
            panelblok6c.getTxtB6CR1().setText(model.getB6CR1());
            panelblok6c.getTxtB6CR2().setText(model.getB6CR2());
            panelblok6c.getTxtB6CR3().setText(model.getB6CR3());
            panelblok6c.getTxtB6CR4().setText(model.getB6CR4());
            panelblok6c.getTxtB6CR5().setText(model.getB6CR5());
            panelblok6c.getTxtB6CR6().setText(model.getB6CR6());
            panelblok6c.getTxtB6CR7().setText(model.getB6CR7());
            panelblok6c.getTxtB6CR8().setText(model.getB6CR8());
            panelblok6c.getTxtB6CR9().setText(model.getB6CR9());
            panelblok6c.getTxtB6CR10().setText(model.getB6CR10());
            panelblok6c.getTxtB6CR11().setText(model.getB6CR11());
            panelblok6c.getTxtB6CR12().setText(model.getB6CR12());
            panelblok6c.getTxtB6CR13().setText(model.getB6CR13());
            panelblok6c.getTxtB6CR14().setText(model.getB6CR14());
            panelblok6c.getTxtB6CR15().setText(model.getB6CR15());
            panelblok6c.getTxtB6CR16().setText(model.getB6CR16());
            panelblok6c.getTxtB6CR17().setText(model.getB6CR17());
            panelblok6c.getTxtB6CR18().setText(model.getB6CR18());
           // panelblok6c.getTxtSebutkanB6CR17().setText(model.getSebutkanB6CR17());

        } catch (EntityException ex) {

            Logger.getLogger(Blok6CController.class.getName()).log(Level.SEVERE, null, ex);
            throw new EntityException("Data Tidak Ditemukan");
        }
    }
}
